package com.dqp.cslggroup;

import android.annotation.SuppressLint;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.dqp.cslggroup.UI.MyApplication;
import com.dqp.cslggroup.bean.academic;

import java.util.ArrayList;
import java.util.List;


public class Fragment_One extends Fragment {
    private RecyclerView mRecyclerView;

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        @SuppressLint("InflateParams") View view = inflater.inflate(R.layout.home_viewpager_layout, null);
        mRecyclerView = view.findViewById(R.id.rec1);
        RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
        mRecyclerView.setLayoutManager(layoutManager);
        initList();
        return view;
    }

    private void initList() {
        ArrayList<String> dataList = new ArrayList<>();
        List<academic> academicList = MyApplication.getDaoInstant().getAcademicDao().loadAll();
        if (academicList.size() > 0) {
            academic academic = academicList.get(0);
            dataList.add("总课程数："+academic.getTotalCourse());
            dataList.add("未通过课程："+academic.getNotPass());
            dataList.add("已通过课程"+academic.getPass());
            dataList.add("绩点："+academic.getGpa());
        }
        Adapter_Diary mAdapter = new Adapter_Diary(dataList);
        mRecyclerView.setAdapter(mAdapter);
    }

}
